numRows = 2
//[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]

var generate = function (numRows) {
    let res = []
    res[1] = [1]
    let count = 2
    while (count <= numRows) {
        res[count] = []
        for (let i = 0; i < count; i++) {
            if (i === 0 || i === count - 1) {
                res[count].push(1)
            } else {
                res[count].push(res[count - 1][i] + res[count - 1][i - 1])
            }
        }
        count++
    }
    res.shift()
    return res;
};
console.log(generate(numRows));
